require "ImguiWin/BaseImguiWindow"
require "Common/GUIFun"

local P = NewClass(BaseImguiWindow, ClassFromFile(...));

local GUILayout = UnityEngine.GUILayout
local GUI = UnityEngine.GUI
local Screen = UnityEngine.Screen
local dontDestroyObjs = nil

local addSpace = 50

function P:Init(params)

end


function P:Cmd(msg, donClose)
	KBEngineLua.player():sendChatMessage(msg)
	if not donClose then
		self._funObj:Close()
	end
end

function P:Show()
	local space = 0
	GUILayout.BeginArea(self:GetFullScreenAreaRect())
	GUILayout.BeginVertical()



	self.guiInfo.scrollPos = GUILayout.BeginScrollView(self.guiInfo.scrollPos, false, true, GUILayout.Width(Screen.width));
	GUILayout.BeginVertical()
	









	-- effect begin
	GUILayout.BeginHorizontal()
	GUILayout.BeginVertical()

	

	local controller = UnityEngine.GameObject.FindObjectOfType(typeof(CameraController))
	if GUIFun.Button("switch camera clear flag: ", true, 0) then
		controller:SwitchCameraClearFlag()
	end

	if GUIFun.Button("early z: "..tostring(controller:isEarlyzEnabled()), true, 0) then
		controller:EnableEarlyz(not controller:isEarlyzEnabled())
	end

	if GUIFun.Button("camera effect: "..tostring(controller:isEffectEnabled()), true, 0) then
		controller:EnableEffect(not controller:isEffectEnabled())
	end

	if GUIFun.Button("show depth: "..tostring(controller:isShowDepthEnabled()), true, 0) then
		controller:EnableShowDepth(not controller:isShowDepthEnabled())
	end

	if GUIFun.Button("output depth: "..tostring(controller:isOutputDepthEnabled()), true, 0) then
		controller:EnableOutputDepth(not controller:isOutputDepthEnabled())
	end

	if GUIFun.Button("depth tex: "..tostring(controller:isDepthTexEnabled()), true, 0) then
		controller:EnableDepthTex(not controller:isDepthTexEnabled())
	end

	if GUIFun.Button("refraction: "..tostring(controller:isRefractionEnabled()), true, 0) then
		controller:EnableRefraction(not controller:isRefractionEnabled())
	end

	if GUIFun.Button("fog: "..tostring(controller:isFogEnabled()), true, 0) then
		controller:EnableFog(not controller:isFogEnabled())
	end

	if GUIFun.Button("waterVolume: "..tostring(controller:isWaterVolumeEnabled()), true, 0) then
		controller:EnableWaterVolume(not controller:isWaterVolumeEnabled())
	end

	if GUIFun.Button("depth of field: "..tostring(controller:isDepthOfFieldEnabled()), true, 0) then
		controller:EnableDepthOfField(not controller:isDepthOfFieldEnabled())
	end

	GUILayout.EndVertical()

	
	GUILayout.FlexibleSpace()
	GUILayout.EndHorizontal()
	-- effect end


	GUILayout.BeginHorizontal()
	GUILayout.EndHorizontal()


	GUILayout.EndVertical()
	GUILayout.EndScrollView();


	GUILayout.BeginHorizontal()

	if GUILayout.Button("close", GUIFun.Height(100)) then
		self._funObj:Close()
	end
	GUILayout.EndHorizontal()
	

	GUILayout.EndVertical()
	GUILayout.EndArea()
end

function P:OnGUI()
	GUIFun.Init()
	GUILayout.Box("", GUILayout.Height(Screen.height), GUILayout.Width(Screen.width))
	self:Show()

	local scrollPosition = self.guiInfo.scrollPos
	local scrollDragSpeed = self.guiInfo.scrollDragSpeed

	ImguiWindowCtrl.ScrollByTouch(scrollPosition, scrollDragSpeed)
end

-- function P:Update()
	
-- end